#include <stdio.h>
#include <unistd.h>
#include <signal.h>

int run_flag = 1;

/*
void fun2(int sig)
{
	run_flag = 0;
}

void fun1(int sig)
{
	printf("received %d\n",sig);
}*/

void fun(int sig)
{
	if(sig == SIGINT)
	{
		run_flag = 0;
	}else if(sig == SIGUSR1)
	{
		printf("received sigusr1\n");
	}
}



int main()
{

	signal(SIGINT,fun);
	signal(SIGUSR1,fun);
	printf("%d\n",getpid());

	while(run_flag == 1)
	{
		printf("nihao\n");
		sleep(1);
	}

	printf("program is finished\n");

	return 0;
}
